package cn.boat.router.broker.partition;

import cn.boat.router.broker.Message;
import cn.boat.router.exception.BoatMQException;

import java.util.List;

public abstract class AbstractPartitionSelector implements PartitionSelector{

    public Partition getPartition(String topic, List<Partition> partitions, Message message) throws BoatMQException {
        if (partitions == null) {
            throw new BoatMQException("There is no available partition for topic " + topic);
        }
        return getPartiton0(topic, partitions, message);
    }
    public abstract Partition getPartiton0(String topic, List<Partition> partitions, Message message) throws BoatMQException;
}
